package com.blb.mvc.util;

import com.blb.mvc.entity.Student;
import org.springframework.core.convert.converter.Converter;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 自定义转换器
 */
public class TimeConvertor implements Converter<String, LocalDateTime> {

    @Override
    public LocalDateTime convert(String s) {
        //id-name-age-address-subject --> Student
        LocalDateTime time = LocalDateTime.parse(s, DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
        return time;
    }
}
